package com.store.utils;


import java.util.UUID;

public class IDGenerator {

    private static StringBuilder sb = new StringBuilder(20);

    public synchronized static String getUUID(String prefix) {
        UUID uuid = UUID.randomUUID();
        sb.setLength(0);
        if (prefix.length() < 5) {
            sb.append(String.format("%-4s", prefix));
        } else {
            sb.append(prefix.substring(0, 4));
        }
        sb.append(uuid.toString().replaceAll("-", ""));
        return sb.toString();
    }
}
